package com.dinggao.crossgo.module.roadbook.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dinggao.crossgo.R;
import com.dinggao.crossgo.core.manage.ApiManager;
import com.dinggao.crossgo.module.roadbook.activity.RoadBookMineActivity;
import com.dinggao.crossgo.module.roadbook.data.RoadBookMineBean;

import java.util.List;

/**
 * created by mapingan on 2018/8/24.
 */
public class RoadBookMineAdapter extends BaseQuickAdapter<RoadBookMineBean.DataBean.ItemsBean,BaseViewHolder> {
    public RoadBookMineAdapter(int layoutResId, @Nullable List<RoadBookMineBean.DataBean.ItemsBean> data) {

        super(R.layout.item_rood_book_mine_recycler, data);
    }




    @Override
    protected void convert(BaseViewHolder helper, RoadBookMineBean.DataBean.ItemsBean item) {


        if (RoadBookMineActivity.show==0){

            helper.getView(R.id.checkbox_mine).setVisibility(View.GONE);

        }else   if (RoadBookMineActivity.show==1){
            helper.getView(R.id.checkbox_mine).setVisibility(View.VISIBLE);
            ((CheckBox) helper.getView(R.id.checkbox_mine)).setChecked(false);


        }else if (RoadBookMineActivity.show==2){
            helper.getView(R.id.checkbox_mine).setVisibility(View.VISIBLE);
            ((CheckBox) helper.getView(R.id.checkbox_mine)).setChecked(true);
        }



        helper.setText(R.id.mine_item_distance,item.getDistince())
                .setText(R.id.mine_item_time,item.getTime())


                .setText(R.id.mine_item_title,item.getTitle())
                .addOnClickListener(R.id.checkbox_mine);

        String url="https://home.sddgxx.com/img/pic/roadBook/defaultRoadBook.jpg";



        //设置图片圆角角度
        RoundedCorners roundedCorners= new RoundedCorners(6);
        //通过RequestOptions扩展功能
        RequestOptions options=RequestOptions.bitmapTransform(roundedCorners)
                .override(400, 300)
                .placeholder(R.drawable.sublist_image)
                .error(R.drawable.sublist_image)
                .centerCrop();


        Glide.with(mContext).load(ApiManager.IMAG_URL+item.getPicPath()).apply(options)
                .into((ImageView) helper.getView(R.id.imageview));




    }
}
